/**
 * Created by Administrator on 2017/07/27 0027.
 */

import React,{Component} from 'react';
import {connect} from 'react-redux';

import HeaderBar from '../../components/headerNav/headBar'
import { Popup } from 'react-weui'
import {dispatchFetchData} from  '../../actions/userAction'
import GiftItem from '../../components/myInfo/giftItem'
import { hashHistory } from 'react-router';
import './index.css'

class MyGiftDetail extends Component{
    constructor(props){
        super(props);
        this.state = {
            detailShow: false,
            giftId:this.props.location.query.giftId
        }
    }
    componentDidMount(){
        const {dispatchFetchData} =this.props
        dispatchFetchData({
            type: 8,
            giftId:this.state.giftId
        })
    }

    render(){
        const style = {
            color: '#999',
            background: 'none',
            padding: 0,
        };
        const {giftDetail,centerModel}=this.props;
        return(
            <div className="panel panel-default" >
                {!this.props.location.query.token &&
                <div className="headerBox">
                    <HeaderBar content='我的礼包' type="3" onClick={
                        ()=>hashHistory.push({
                            pathname: '/myGift',
                            query: {
                                phone:this.state.phone
                            }
                        })
                    }/>
                </div>}
                {
                    !this.props.location.query.token &&
                    <div className="het"></div>
                }
                <div >
                    <div id="gift_detail">
                        {
                            giftDetail&&
                            <div dangerouslySetInnerHTML={{__html:centerModel.detail}}></div>
                        }
                    </div>
                </div>
            </div>

        )
    }
}

function mapStateToProps(state) {
    return{
        giftDetail:state.userReducer.giftDetail,
        centerModel:state.userReducer.centerModel
    }
}

export default connect(
    mapStateToProps, {dispatchFetchData}
)(MyGiftDetail)